@extends('admin.layout')
@section('title','订单列表')
@section('body')


    <table class="layui-table " >
        <colgroup>

        </colgroup>
        <thead>
        <tr>
            <th>酒店名称</th>
            {{--<th>正面</th>--}}
            {{--<th>反面</th>--}}
            {{--<th>执照</th>--}}
            <th>时间</th>
            <th>法人</th>
            <th>手机</th>
            <th>身份证号</th>
            <th>地址</th>
            <th>销售额</th>
            <th>提成</th>
            <th>已打款</th>
            <th>剩余打款</th>
            <th>提成</th>
            <th width="100px">操作</th>
        </tr>
        </thead>
        <tbody>
        @foreach($shop as $value)
            <tr  onclick=" window.location.href='{{url('check/chest',['shop'=>$value->id])}}'"
                    class="@if($value->status==1) bg-warning  @elseif($value->status==0) bg-success @endif">
                <td>{{$value->grogsgopname}}</td>
                {{--<td><img style="width: 100px;height: 60px;" src="{{$value->Zimage}}" alt=""></td>--}}
                {{--<td><img style="width: 100px;height: 60px;" src="{{$value->Bimage}}" alt=""></td>--}}
                {{--<td><img style="width: 100px;height: 60px;" src="{{$value->Yimage}}" alt=""></td>--}}
                <td>{{$value->addtime}}</td>
                <td>{{$value->name}}元</td>
                <td>{{$value->tel}}</td>
                <td>{{$value->card}}</td>
                <td >
                    {{ $value->district}}{{$value->address}}
                </td>
                <td>{{$value->sell}}元</td>
                <td>{{number_format($value->sell*$value->pushmoney/100,2)}}元</td>
                <td>{{$value->dakuan}}元</td>
                <td>{{number_format($value->sell*$value->pushmoney/100-$value->dakuan,2)}}元</td>
                <td> {{$value->pushmoney}}%</td>
                <td>

                    @if($admin_type==2)
                            @if($value->status==1)
                                <button  class="btn btn-danger"  onclick="pass('{{$value->id}}')">通过</button>
                            <button  class="btn btn-info" onclick="del('{{$value->id}}')">删除</button>

                        @elseif($value->status==0)
                                <button  class="btn btn-primary" onclick="rate('{{$value->id}}')">提成</button>
                                <button  class="btn btn-success" onclick="sell('{{$value->id}}','{{number_format($value->sell*$value->pushmoney/100,2)-$value->dakuan}}')">打款</button>
                                <button  class="btn btn-info" onclick="del('{{$value->id}}')">删除</button>
                            @endif

                        @else
                            @if($value->status==1)
                                <button  class="btn btn-danger" disabled onclick="pass('{{$value->id}}')">待审核</button>
                            <button  class="btn btn-info" onclick="del('{{$value->id}}')">删除</button>

                        @elseif($value->status==0)
                                <button  class="btn btn-primary" onclick="rate('{{$value->id}}')">提成</button>
                                <button  class="btn btn-success" onclick="sell('{{$value->id}}','{{number_format($value->sell*$value->pushmoney/100,2)-$value->dakuan}}')">打款</button>
                            <button  class="btn btn-info" onclick="del('{{$value->id}}')">删除</button>
                            @endif
                    @endif


                </td>
            </tr>
        @endforeach
        </tbody>

    </table>
    {!! $shop->links() !!}
@endsection
@section('js')

    <script>
        @if(Session::has('message'))
             layer.msg("{{Session::get("message")}}");
        {{Session::forget('message')}}
        @endif
        function pass(id) {
            layer.open({
                title:"审核",
                content:'是否通过？<br/>选择地区 <form id="pass" method="post" > <select name="district" id="">@foreach($area as $value)<option value="{{$value->area}}">{{$value->area}}</option>@endforeach</select><input type="hidden" name="id" value='+id+'><br/>选择分类 <br/><select name="class_id" id="">@foreach($class as $value)<option value="{{$value->id}}">{{$value->name}}</option>@endforeach<br/><br/></select>{{csrf_field()}}</form>',
                yes:function () {
                    $("#pass").submit();
                }
            });
            event.stopPropagation();
        }

        function rate(id) {
            layer.open({
                title:"设置提成比例",
                content:'<form id="rate" method="post"><input type="hidden" name="id" value='+id+'><input type="number" name="rate"   placeholder="提成比例">%{{csrf_field()}} </form>',
                yes:function () {
                    $("#rate").submit();
                }
            });
            event.stopPropagation();
        }

        function sell(id,money) {
            layer.open({
                title:"是否打款？",
                content:'<form id="sell" method="post" enctype="multipart/form-data"><div id="money_addr"></div><input type="hidden" name="shop_id" value='+id+'><input type="number" class="form-control" name="money"  value='+money+'  placeholder="本次打款金额,单位元"></br></br>打款凭证<input type="file" name="pic">{{csrf_field()}} </form>',
                yes:function () {
                    $("#sell").submit();
                }
            });
            $.get({
                url:"http://egui.gebixianxiang.com:8081/BGoods/Data/betbankmess",
                data:{"shopid":id},
                success:function (res) {
                    if(res.bank!=null){
                        var moeny_addr='姓名：'+res.bank.accountname+",<br>账户:"+res.bank.bankaccount+"<br>银行："+res.bank.depositbank+"<br>分行："+res.bank.bankingoutlets+"<br>";
                        $("#money_addr").html(moeny_addr);
                    }else{
                        $("#money_addr").html("无打款信息");
                    }
                }
            });
            event.stopPropagation();
        }
        
        function del(id) {
            layer.open({
                title:"提示？",
                content:'是否删除<form id="del" method="post" action="{{url('check/shop_del')}}"><input type="hidden" name="shop_id" value='+id+'>{{csrf_field()}} </form>',
                yes:function () {
                    $("#del").submit();
                }
            });
            event.stopPropagation();
        }
    </script>

@endsection

